//
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

html, body {
  background-color: #f0f8ff;
  margin: 0;
  height: 100%;
}

body, p {
  font-family: system-ui,
               -apple-system, BlinkMacSystemFont,
               'Segoe UI',
               Roboto,
               Oxygen-Sans,
               Ubuntu,
               Cantarell,
               'Helvetica Neue',
               Arial, sans-serif;
}

body, input, textarea, select {
  font-size: 1rem;
}

@media (prefers-color-scheme: dark) {
  body {
    filter: invert(90%) hue-rotate(180deg) contrast(105%);
  }
}

select {
  padding: 0.3em;
  border-radius: 0.3em;
}

textarea, pre {
  font-family: ui-monospace,
               Menlo, Monaco,
               'Cascadia Mono', 'Segoe UI Mono',
               'Roboto Mono',
               'Oxygen Mono',
               'Ubuntu Monospace',
               'Source Code Pro',
                Consolas,
               'Courier New', monospace;
}

textarea#query:focus {
  border-color: #fa8072;
}

main {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 40% 60%;
  height: 100vh;
}

#header {
  grid-column: 1 / -1;
  background-color: #1597ec;
  font-size: 2.25em;
  font-family: Roboto, Arial, sans-serif;
  font-weight: 700;
  padding: 0.5rem 1rem;
}

#header .header-right {
  float: right;
  display: flex;
  align-items: center;
  gap: 0.5em;
}

#header a {
  text-decoration: none;
  color: #fff;
}

.avatar {
  border-radius: 50%;
  border: 1px solid #0f73b5;
  width: 32px;
  height: 32px;
  object-fit: cover;
}

/* Undos dark mode filter for avatar images */
@media (prefers-color-scheme: dark) {
  .avatar {
    filter: invert(90%) hue-rotate(180deg) contrast(105%);
  }
}

#header #share-link {
  float: right;
  font-size: 0.5em;
  padding: 0.4em 0.6em;
  background-color: #0f73b5;
  border-radius: 0.5em;
  border: 1px solid #0f73b5;
  color: #fff;
  cursor: pointer;
}

#header #share-link:hover {
  background-color: #c74dd1;
  border-color: #1597ec;
}

#header #share-link:active {
  border-color: #fff;
  border-style: dashed;
}

.left-section {
  box-sizing: border-box;
  padding: 1rem;
}

.right-section {
  overflow-y: auto;
  box-sizing: border-box;
  padding: 1rem;
  height: 100%
}

@media (max-width: 1600px) {
  main {
    display: block;
  }
  .right-section {
    overflow-y: initial;
  }
  textarea#query, #editor {
    height: auto;
  }
}

textarea#query,
#editor {
  width: 100%;
  min-height: 20em;
  height: 40vh;
  margin: 0;
  padding: 0.7em;
  outline: none;
  border: 1px solid #ccc;
  border-radius: 0.5rem;
  margin-bottom: 0.7em;
  resize: none;
}

#editor {
  display: none;
}

fieldset {
  display: inline-block;
  margin-bottom: 0.5em;
  width: fit-content;
  border-radius: 0.5rem;
}

label {
  margin-right: 0.5em;
}

input[type='checkbox'] {
  vertical-align: bottom;
}

input[type='submit'] {
  background-color: #0f73b5;;
  border-radius: 0.5em;
  border: 1px solid #0f73b5;
  color: #fff;
  cursor: pointer;
  font-size: 1.1em;
  margin-left: 1em;
  margin-top: 0.5em;
  max-height: 2.5em;
  max-width: 6em;
  min-width: 5em;
  padding: 0.5em;
}

input[type='submit']:hover {
  background-color: #1597ec;
  border-color: #1597ec;
}

form {
  container-type: inline-size;
}

.options {
  display: flex;
}

.mode-option {
  white-space: nowrap;
}

.select-options {
  display: inline-block;
  margin-right: 0.5em;
  margin-bottom: 0.5em;
}

.result > h3 {
  margin-top: 1.5em;
  margin-bottom: 0;
  background-color: #1597ec;
  color: #fff;
  width: fit-content;
  padding: 0.25em 0.5em;
  border-radius: 0.5em 0.5em 0 0;
}

.result > h3:first-of-type {
  margin-top: auto;
}

h3.statement {
  background-color: #3cb151;
  color: #fff;
}

pre.output {
  background-color: #fafafa;
  border: 1px dashed #aaa;
  padding: 0.5em;
  margin-top: 0;
  overflow: auto;
}

pre.output code.hljs {
  background-color: transparent;
  padding: 0;
}

#error {
  display: inline-block;
  background-color: #f1a7a7;
  margin: 0;
  padding: 1em;
}

.error-highlight {
  background-color: #ff0;
}

.error-highlight .ast-col.highlighted,
.error-highlight .ast-col.highlighted-sticky {
  background-color: #e00;
}
.error-highlight .ast-col.highlighted-sticky-suspended {
  background-color: #dd0;
}

pre.output > table {
  border-collapse: collapse;
  border: 1px solid #066eb3;
  cursor: default;
}

pre.output th {
  background-color: #1597ec;
  color: #fff;
}

pre.output th, pre.output td {
  border-right: 1px solid #066eb3;
  padding: 0.25em 0.5em;
  white-space: pre-wrap;
}

pre.output tbody tr:nth-child(even) {
  background: #f0f8ff;
}

pre.output td:first-child {
  background-color: #fafafa;
  color: #aaa;
  font-size: smaller;
  text-align: right;
}

pre.output tbody tr:hover {
  background: #eee;
}

hr {
  height: 1px;
  background-color: #111;
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}

.ast-node {
  font-weight: bold;
}

/* For highlighting all column ID nodes when you hover over one of them. */
.ast-col.highlighted,
.ast-col.highlighted-sticky{
  background-color: #ff5;
  outline: 1px solid #ffa500;
}

.ast-col.highlighted-sticky-suspended {
  background-color: #ffff5522;
  outline: 1px solid #ffa50044;
}

/* For highlighting the source column when you hover over a column ID node. */
.ast-col-src .ast-col.highlighted,
.ast-col-src .ast-col.highlighted-sticky{
  background-color: #5f5;
  outline: 1px solid #0f0;
}

.ast-col-src .ast-col.highlighted-sticky-suspended {
  background-color: #55ff5522;
  outline: 1px solid #00ff0044;
}

